package com.tao.erp.procurement.pojo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import com.tao.erp.emp.pojo.Emp;
import com.tao.erp.goods.pojo.Supplier;
import com.tao.erp.utils.format.FormatUtil;

public class Order {
	public static final Integer ORDER_ORDERTYPE_OF_BUY = 1;
	public static final Integer ORDER_ORDERTYPE_OF_SALE = 2;
	public static final Integer ORDER_ORDERTYPE_OF_RETURN_BUY = 3;
	public static final Integer ORDER_ORDERTYPE_OF_RETURN_SALE = 4;
	
	public static final String ORDER_ORDERTYPE_OF_BUY_VIEW = "采购";
	public static final String ORDER_ORDERTYPE_OF_SALE_VIEW = "销售";
	public static final String ORDER_ORDERTYPE_OF_RETURN_BUY_VIEW = "采购退货";
	public static final String ORDER_ORDERTYPE_OF_RETURN_SALE_VIEW = "销售退货";
	
	public static final Integer ORDER_TYPE_OF_BUY_NO_CHECK = 111;
	public static final Integer ORDER_TYPE_OF_BUY_CHECK_PASS = 121;
	public static final Integer ORDER_TYPE_OF_BUY_CHECK_NO_PASS = 120;
	public static final Integer ORDER_TYPE_OF_BUY_BUYING = 131;
	public static final Integer ORDER_TYPE_OF_BUY_IN_STORE = 141;
	public static final Integer ORDER_TYPE_OF_BUY_COMPLETE = 199;
	
	public static final String ORDER_TYPE_OF_BUY_NO_CHECK_VIEW = "未审核";
	public static final String ORDER_TYPE_OF_BUY_CHECK_PASS_VIEW = "通过";
	public static final String ORDER_TYPE_OF_BUY_CHECK_NO_PASS_VIEW = "驳回";
	public static final String ORDER_TYPE_OF_BUY_BUYING_VIEW = "采购中";
	public static final String ORDER_TYPE_OF_BUY_IN_STORE_VIEW = "入库中";
	public static final String ORDER_TYPE_OF_BUY_COMPLETE_VIEW = "结单";
	
	public static final Integer ORDER_TYPE_OF_SALE_NO_CHECK = 211;
	public static final Integer ORDER_TYPE_OF_SALE_CHECK_PASS = 221;
	
	public static final String ORDER_TYPE_OF_SALE_NO_CHECK_VIEW = "未审核";
	public static final String ORDER_TYPE_OF_SALE_CHECK_PASS_VIEW = "通过";
	
	public static final Map<Integer, String> orderTypeMap = new HashMap<Integer, String>();
	
	public static final Map<Integer, String> buyTypeMap = new TreeMap<Integer, String>();
	public static final Map<Integer, String> saleTypeMap = new TreeMap<Integer, String>();
	
	private static final Map<Integer, String> typeMap = new HashMap<Integer, String>();
	
	static{
		orderTypeMap.put(ORDER_ORDERTYPE_OF_BUY, ORDER_ORDERTYPE_OF_BUY_VIEW);
		orderTypeMap.put(ORDER_ORDERTYPE_OF_SALE, ORDER_ORDERTYPE_OF_SALE_VIEW);
		orderTypeMap.put(ORDER_ORDERTYPE_OF_RETURN_BUY, ORDER_ORDERTYPE_OF_RETURN_BUY_VIEW);
		orderTypeMap.put(ORDER_ORDERTYPE_OF_RETURN_SALE, ORDER_ORDERTYPE_OF_RETURN_SALE_VIEW);

		buyTypeMap.put(ORDER_TYPE_OF_BUY_NO_CHECK, ORDER_TYPE_OF_BUY_NO_CHECK_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_CHECK_PASS, ORDER_TYPE_OF_BUY_CHECK_PASS_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_CHECK_NO_PASS, ORDER_TYPE_OF_BUY_CHECK_NO_PASS_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_BUYING, ORDER_TYPE_OF_BUY_BUYING_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_IN_STORE, ORDER_TYPE_OF_BUY_IN_STORE_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_COMPLETE, ORDER_TYPE_OF_BUY_COMPLETE_VIEW);
		
		saleTypeMap.put(ORDER_TYPE_OF_SALE_NO_CHECK, ORDER_TYPE_OF_SALE_NO_CHECK_VIEW);
		saleTypeMap.put(ORDER_TYPE_OF_SALE_CHECK_PASS, ORDER_TYPE_OF_SALE_CHECK_PASS_VIEW);
		
		typeMap.putAll(buyTypeMap);
		typeMap.putAll(saleTypeMap);
	}
	private Integer uuid;
	private String ordernum;
	private Integer totalnum;
	private Integer supplieruuid;

	private Long createtime;
	private Long checktime;
	private Long endtime;
	private Integer ordertype;
	private Integer type;
	private Double totalprice;

	
	private String createTimeView;
	private String checkTimeView;
	private String endTimeView;
	private String orderTypeView;
	private String typeView;
	private String totalPriceView;
	
	private Emp creater=new Emp();
	private Emp checker=new Emp();
	private Emp completer=new Emp();
	private Supplier supplier=new Supplier();
	
	private Integer totalnumMin;
	private Integer totalnumMax;
	private Double totalpriceMin;
	private Double totalpriceMax;
	private Long createtimeMin;					//下单时间
	private Long createtimeMax;					//下单时间
	private Date createTimeViewMin;				//页面下单时间
	private Date createTimeViewMax;				//页面下单时间
	private Long checktimeMin;					//审核时间
	private Long checktimeMax;					//审核时间
	private Date checkTimeViewMin;				//页面审核时间
	private Date checkTimeViewMax;				//页面审核时间
	
	
	public Long getChecktimeMin() {
		return checktimeMin;
	}

	public void setChecktimeMin(Long checktimeMin) {
		this.checktimeMin = checktimeMin;
	}

	public Long getChecktimeMax() {
		return checktimeMax;
	}

	public void setChecktimeMax(Long checktimeMax) {
		this.checktimeMax = checktimeMax;
	}

	public Date getCheckTimeViewMin() {
		return checkTimeViewMin;
	}

	public void setCheckTimeViewMin(Date checkTimeViewMin) {
		this.checkTimeViewMin = checkTimeViewMin;
		this.checktimeMin=checkTimeViewMin.getTime();
	}

	public Date getCheckTimeViewMax() {
		return checkTimeViewMax;
	}

	public void setCheckTimeViewMax(Date checkTimeViewMax) {
		this.checkTimeViewMax = checkTimeViewMax;
		this.checktimeMax=checkTimeViewMax.getTime();
	}

	private List<OrderDetail> orderDetailList;
	
	
	public List<OrderDetail> getOrderDetailList() {
		return orderDetailList;
	}

	public void setOrderDetailList(List<OrderDetail> orderDetailList) {
		this.orderDetailList = orderDetailList;
	}

	public Integer getTotalnumMin() {
		return totalnumMin;
	}

	public void setTotalnumMin(Integer totalnumMin) {
		this.totalnumMin = totalnumMin;
	}

	public Integer getTotalnumMax() {
		return totalnumMax;
	}

	public void setTotalnumMax(Integer totalnumMax) {
		this.totalnumMax = totalnumMax;
	}

	public Long getCreatetimeMin() {
		return createtimeMin;
	}

	public void setCreatetimeMin(Long createtimeMin) {
		this.createtimeMin = createtimeMin;
	}

	public Long getCreatetimeMax() {
		return createtimeMax;
	}

	public void setCreatetimeMax(Long createtimeMax) {
		this.createtimeMax = createtimeMax;
	}

	public Date getCreateTimeViewMin() {
		return createTimeViewMin;
	}

	public void setCreateTimeViewMin(Date createTimeViewMin) {
		this.createTimeViewMin = createTimeViewMin;
		if(createTimeViewMin!=null){
			this.createtimeMin=createTimeViewMin.getTime();
		}
	}

	public Date getCreateTimeViewMax() {
		return createTimeViewMax;
	}

	public void setCreateTimeViewMax(Date createTimeViewMax) {
		this.createTimeViewMax = createTimeViewMax;
		if(createTimeViewMax!=null){
			this.createtimeMax=createTimeViewMax.getTime();
		}
	}

	public Double getTotalpriceMin() {
		return totalpriceMin;
	}

	public void setTotalpriceMin(Double totalpriceMin) {
		this.totalpriceMin = totalpriceMin;
	}

	public Double getTotalpriceMax() {
		return totalpriceMax;
	}

	public void setTotalpriceMax(Double totalpriceMax) {
		this.totalpriceMax = totalpriceMax;
	}

	public Integer getUuid() {
		return uuid;
	}

	public void setUuid(Integer uuid) {
		this.uuid = uuid;
	}

	public String getOrdernum() {
		return ordernum;
	}

	public void setOrdernum(String ordernum) {
		this.ordernum = ordernum;
	}

	public Integer getTotalnum() {
		return totalnum;
	}

	public void setTotalnum(Integer totalnum) {
		this.totalnum = totalnum;
	}

	public Integer getSupplieruuid() {
		return supplieruuid;
	}

	public void setSupplieruuid(Integer supplieruuid) {
		this.supplieruuid = supplieruuid;
	}

	public Long getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Long createtime) {
		this.createtime = createtime;
		this.createTimeView=FormatUtil.formatDate(createtime);
	}

	public Long getChecktime() {
		return checktime;
	}

	public void setChecktime(Long checktime) {
		this.checktime = checktime;
		this.checkTimeView=FormatUtil.formatDate(checktime);
	}

	public Long getEndtime() {
		return endtime;
	}

	public void setEndtime(Long endtime) {
		this.endtime = endtime;
		this.endTimeView=FormatUtil.formatDate(endtime);
	}

	public Integer getOrdertype() {
		return ordertype;
	}

	public void setOrdertype(Integer ordertype) {
		this.ordertype = ordertype;
		this.orderTypeView=orderTypeMap.get(ordertype);
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
		this.typeView=typeMap.get(type);
	}

	public Double getTotalprice() {
		return totalprice;
	}

	public void setTotalprice(Double totalprice) {
		this.totalprice = totalprice;
		this.totalPriceView= FormatUtil.formatMoney(totalprice);
	}

	public String getCreateTimeView() {
		return createTimeView;
	}

	public void setCreateTimeView(String createTimeView) throws ParseException {
		this.createTimeView = createTimeView;
		Date date = new SimpleDateFormat("yyyy-MM-dd").parse(createTimeView);
		this.createtime=date.getTime();
	}

	public String getCheckTimeView() {
		return checkTimeView;
	}

	public void setCheckTimeView(String checkTimeView) throws ParseException {
		this.checkTimeView = checkTimeView;
		Date date = new SimpleDateFormat("yyyy-MM-dd").parse(checkTimeView);
		this.checktime=date.getTime();
	}

	public String getEndTimeView() {
		return endTimeView;
	}

	public void setEndTimeView(String endTimeView) throws ParseException {
		this.endTimeView = endTimeView;
		Date date = new SimpleDateFormat("yyyy-MM-dd").parse(endTimeView);
		this.endtime=date.getTime();
	}

	public String getOrderTypeView() {
		return orderTypeView;
	}

	public void setOrderTypeView(String orderTypeView) {
		this.orderTypeView = orderTypeView;
	}

	public String getTypeView() {
		return typeView;
	}

	public void setTypeView(String typeView) {
		this.typeView = typeView;
	}

	public String getTotalPriceView() {
		return totalPriceView;
	}

	public void setTotalPriceView(String totalPriceView) {
		this.totalPriceView = totalPriceView;
	}

	public Emp getCreater() {
		return creater;
	}

	public void setCreater(Emp creater) {
		this.creater = creater;
	}

	public Emp getChecker() {
		return checker;
	}

	public void setChecker(Emp checker) {
		this.checker = checker;
	}

	public Emp getCompleter() {
		return completer;
	}

	public void setCompleter(Emp completer) {
		this.completer = completer;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	@Override
	public String toString() {
		return "Order [uuid=" + uuid + ", ordernum=" + ordernum + ", totalnum="
				+ totalnum + ", supplieruuid=" + supplieruuid + ", createtime="
				+ createtime + ", checktime=" + checktime + ", endtime="
				+ endtime + ", ordertype=" + ordertype + ", type=" + type
				+ ", totalprice=" + totalprice + ", createTimeView="
				+ createTimeView + ", checkTimeView=" + checkTimeView
				+ ", endTimeView=" + endTimeView + ", orderTypeView="
				+ orderTypeView + ", typeView=" + typeView
				+ ", totalPriceView=" + totalPriceView + ", creater=" + creater
				+ ", checker=" + checker + ", completer=" + completer
				+ ", supplier=" + supplier + "]";
	}

	
	
	
}
